{% import 'macro.html.twig' as web_macro %}
<table class="table table-striped table-hover" id="quiz-table">
  <thead>
  <tr>
    <th><input type="checkbox" autocomplete="off" class="js-select-all"></th>
    <th width="20%">{{ 'course.testpaper_manage.name'|trans }}</th>
    <th>{{ 'course.testpaper_manage.status'|trans }}</th>
    <th>{{ 'course.testpaper_manage.statistics'|trans }}</th>
    <th >{{ 'course.testpaper_manage.update'|trans }}</th>
    <th width="15%">{{ 'course.testpaper_manage.operation'|trans }}</th>
  </tr>
  </thead>
  <tbody>
  {% for testpaper in testpapers %}
    {% set user = users[testpaper.updated_user_id] %}
    <tr data-role='item'>
      <td><input value="{{ testpaper.id }}" type="checkbox" class="js-checkbox" data-id="{{ testpaper.id }}"></td>
      <td>
        <a class="link-primary" href="{{ path('question_bank_manage_testpaper_preview', {id: questionBank.id, assessmentId: testpaper.id}) }}" target="_blank">{{ testpaper.name|plain_text(40) }}</a>
      </td>
      <td>
        {% if testpaper.status == 'draft' %}{{'course.testpaper_manage.testpaper_status.draft'|trans}}{% endif %}
        {% if testpaper.status == 'open' %}{{'course.testpaper_manage.testpaper_status.open'|trans}}{% endif %}
        {% if testpaper.status == 'closed' %}{{'course.testpaper_manage.testpaper_status.closed'|trans}}{% endif %}
      </td>
      <td>
        {{'course.testpaper_manage.count'|trans({'%itemCount%': testpaper.item_count})}} <span class="color-gray">/</span> {{'course.testpaper_manage.score'|trans({'%score%': testpaper.total_score})}}
      </td>
      <td>
        {{ web_macro.user_link(user) }}
        <br />
        <span class="color-gray text-sm">{{testpaper.updated_time | date('Y-n-d H:i:s')}}</span>
      </td>
      <td>
        <div class="btn-group">
          <a class="link-primary" href="{{ path('question_bank_manage_testpaper_preview', {id: questionBank.id, assessmentId: testpaper.id}) }}"  target="_blank">{{'course.btn.preview'|trans}}</a>
          <a class="ml10 link-primary" href="#" type="button" class="dropdown-toggle" data-toggle="dropdown">
            {{'course.btn.more'|trans}}<i class="es-icon es-icon-arrowdropdown"></i>
          </a>
          <ul class="dropdown-menu pull-right">
            {% if testpaper.status in ['draft', 'closed'] %}
              <li><a class="open-testpaper" href="javascript:" title="{{'course.testpaper_manage.publish_tips'|trans({'%name%': testpaper.name })}}" data-url="{{ path('question_bank_manage_testpaper_publish', {id: questionBank.id, assessmentId: testpaper.id}) }}">
                <span class="es-icon es-icon--check-circle mrm"></span> {{'course.testpaper_manage.publish_btn'|trans}}
              </a></li>
            {% endif %}
            {% if testpaper.status == 'open' %}
              <li><a class="close-testpaper" href="javascript:" title="
                {% if testpaperActivities[testpaper.id]|default(null) %}
                  {{'course.testpaper_manage.testpaper_quoted_close_tips'|trans({'%taskName%':setting('course.task_name')|default('admin.setting_course.task'|trans)})}}
                {% else %}
                  {{'course.testpaper_manage.close_tips'|trans({'%name%': testpaper.name })}}
                {% endif %}"
              data-url="{{ path('question_bank_manage_testpaper_close', {id: questionBank.id, assessmentId: testpaper.id}) }}">
                <span class="es-icon es-icon-close01 mrm"></span> {{'course.testpaper_manage.close_btn'|trans}}
              </a></li>
            {% endif %}

            {% if testpaper.status == 'draft' %}
              <li><a href="{{ path('question_bank_manage_testpaper_edit', {id: questionBank.id, assessmentId: testpaper.id}) }}"><span class="glyphicon glyphicon-edit mrm"></span> {{'my.teaching.question_bank.testpaper.edit'|trans}}</a></li>
              <li><a href="javascript:" class="js-delete-btn" data-name='{{'course.testpaper_manage.testpaper'|trans}}' data-url="{{ path('question_bank_manage_testpaper_delete', {id: questionBank.id, assessmentId: testpaper.id}) }}">
                <span class="es-icon es-icon-delete mrm"></span> {{'course.testpaper_manage.delete_btn'|trans}}
              </a></li>
            {% endif %}
            <li><a href="{{ path('question_bank_manage_testpaper_export', {id: questionBank.id, assessmentId: testpaper.id}) }}"><span class="glyphicon glyphicon-export mrm"></span>{{ 'course.testpaper_manage.export'|trans }}</a></li>
          </ul>
        </div>
      </td>
    </tr>
  {% else %}
    <tr>
      <td colspan="20">
        {% if isSearch is defined %}
          <div class="empty">{{ 'my.teaching.question_bank.testpaper.empty'|trans }}</div>
        {% else %}
          {{ 'course.testpaper_manage.empty'|trans({'%createUrl%':path('question_bank_manage_testpaper_create', {id: questionBank.id})})|raw }}
        {% endif %}
      </td>
    </tr>
  {% endfor %}
  </tbody>
</table>
<div>
  <label class="checkbox-inline"><input type="checkbox" autocomplete="off" class="js-select-all"> {{'course.question_manage.select_all'|trans}}</label>
  <span class="color-gray mlm vertical-middle">{{ 'my.teaching.question_bank.question.selected'|trans }}：<span class="js-select-number">0</span></span>
  <button class="cd-btn cd-btn-default cd-btn-sm mlm js-batch-delete" data-name="{{ 'course.testpaper_manage.testpaper'|trans }}" data-url="{{ path('question_bank_manage_testpaper_batch_delete', {id: questionBank.id}) }}">
    {{ 'course.testpaper_manage.delete_btn'|trans }}
  </button>
</div>

{{ web_macro.ajax_paginator(paginator) }}
